<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/css/bootstrap.css" rel="stylesheet" />
<link href="/css/bootstrap.min.css" rel="stylesheet" />
<link href="/css/bootstrap-responsive.css" rel="stylesheet" />
<link href="/css/bootstrap-responsive.min.css" rel="stylesheet" />
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/jquery.js" type="text/javascript"></script>
<script src="/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript" language = "javascript">
function login(username,passwd)
{
	var postStr = "username="+username+"&passwd="+passwd;
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("div_login").innerHTML=xmlhttp.responseText;
			//document.getElementById("div_ifoundyou_alert").innerHTML="";
			if (xmlhttp.responseText.indexOf('用户名') < 0){
				document.getElementById("div_submit").innerHTML="<input type='submit' value='提交' class='btn'>";
				document.getElementById("div_join").innerHTML="<a href='javascript:void(0);' onclick='return join({{ t_id }});'  class='btn btn-success'>我要参加</a><br>";
			}
		}
	}
    xmlhttp.open("POST", "/login", true);  
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
    xmlhttp.send(postStr);  
}

function logout()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			window.location.href="/home";
		}
	}
    xmlhttp.open("GET", "/logout", true);  
    xmlhttp.send();
}

function isempty(str){
	var i = 0;
	for(i=0;i<str.length;++i){
		if (str[i] == ' ')
			continue;
		else
			break;
	}
	if(i == str.length){
		return 1;
	}
	return 0;
}

function check(){
	if(isempty(new_sub_form.title.value)){
		alert('标题不能为空！');
		return false;
	}
	
	if(isempty(new_sub_form.body.value)){
		alert('内容不能为空！');
		return false;
	}
}

function checksub(){
	if(isempty(answer_form.text.value)){
		alert('内容不能为空！');
		return false;
	}
}
</script>
<style>
#div_outmenu{
	border-bottom-color:#093;
	height:auto;
}
</style>
</head>

<body>
<div id="div_outmenu" style="height:40px" class="container">
    <div id="div_menu" class="pull-left">
    <ul class="nav nav-pills">
    	<li 
        {% if sign == 'home' %}
        	class="active"
        {% endif %}
        ><a href="/home">首页</a></li>
    	<li 
        {% if sign == 'news' %}
        class="active"
        {% endif %}
        ><a href="/news">新闻</a></li>
    	<li 
        {% if sign == 'problem' %}
        class="active"
        {% endif %}
        ><a href="/problem">答疑</a></li>
    	<li 
        {% if sign == 'relax' %}
        class="active"
        {% endif %}
        ><a href="/relax">放松</a></li>
    	<li 
        {% if sign == 'tutsau' %}
        class="active"
        {% endif %}
        ><a href="/tutsau">吐槽</a></li>
    	<li 
        {% if sign == 'ifoundyou' %}
        class="active"
        {% endif %}
        ><a href="/ifoundyou">IfoundYou<i class="icon-map-marker"></i></a></li>
    </ul>
	</div>
    <div id="div_login" class="pull-right">
    {% if username %}
    <div class="btn-group">
    <a class="btn btn-link dropdown-toggle" data-toggle="dropdown"><i class="icon-user"></i>{{ username }} <span class="caret"></span></a>
    <ul class="dropdown-menu">
	<li><a href="/userinfo"><i class="icon-user"></i>查看资料</a></li>
	<li><a href="/edit"><i class="icon-pencil"></i>修改信息</a></li>
	<li><a href="/change_passwd"><i class="icon-wrench"></i>修改密码</a></li>
	<li class="divider"></li>
	<li><a href="javascript:void(0);" onclick="return logout();"><i class="icon-off"></i>退出</a></li>
    </ul>
    </div>
        	<a href="/message"><i class="icon icon-envelope"></i>({{ msg_count }})</a>
        {% else %}
            <form name="f_login" class="form-inline">
                <label class="control-label"></label><input type="text" name="username" placeholder='用户名' >
                <input type="password" name="passwd" placeholder='密码'>
                <a href="javascript:void(0);" onclick="return login(f_login.username.value,f_login.passwd.value);" >登陆</a>|<a href="/regiest">注册</a>|<a href="/forgetpasswd">忘记密码</a>
            </form>
    {% endif %}
</div>
</div>
<hr />
</body>
</html>
